<?php
session_start();
$username = $_SESSION['username'];
$password = $_SESSION['password'];
$filepath = $_FILES['mypicture']['tmp_name'][0];

$url = "http://localhost:8080/moms-diary/services/picture/gallery";
//$username="rm.herwidodo@babytivities.com";
//$password="e8HSG6Mlj>";

$postFields = array();

//files
$postFields['file'] = "@".$filepath;

$auth = $username.":".$password;

$curl_handle = curl_init($url);

curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_USERPWD, $auth);
curl_setopt($curl_handle, CURLOPT_POST, true);
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $postFields);

//execute the API Call
$returned_data = curl_exec($curl_handle);
$return =  curl_getinfo($curl_handle);

echo $returned_data;


